<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>

<script>
  var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  console.log(arr.push(10));
  console.log(arr);

  console.log(arr.pop());
  console.log(arr);

  console.log(arr.unshift(0));
  console.log(arr);

  console.log(arr.shift());
  console.log(arr);

  console.log(arr.splice(1, 3, "two", "three", "four"));
  console.log(arr);

  arr.splice(1, 3, 2, 3, 4);
  console.log(arr);

  console.log(arr.reverse());
  console.log(arr);

  console.log(
    arr.sort(function (a, b) {
      return a - b;
    })
  );
  console.log(arr);

  //   不改变原数组
  console.log(arr.concat([10, 11, 12]));

  console.log(arr.join("~"));

  console.log(arr.slice(1, 4));

  console.log(arr.indexOf(2));

  console.log(arr.lastIndexOf(8));

  console.log(arr.includes(2));

  console.log(
    arr.forEach(function (item) {
      console.log(item);
    })
  );

  console.log();
</script>
